nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]

cur = nums[0]
max_num = cur
for i in range(1, len(nums)):
    cur = max(nums[i], cur + nums[i])
    max_num = max(max_num, cur)
print(max_num)
